<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <!-- 引入刚刚下载的 ECharts 文件 -->
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{/echarts/china.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="UTF-8"></script>
    <style>
        .layui-text h3{
            font-size: 18px;
            padding-top: 10px;
        }
        .layui-timeline-axis{
            padding-top: 20px;
        }
        .layui-text p {
            margin: -20px 0px 15px 5px;
        }
        .layui-timeline-item{
            padding-top: 10px;
        }
        .layui-timeline-title{
            padding-top: 10px;
            margin-bottom: 0px;
        }
    </style>
</head>
<body class="childrenBody">
<div>
    <div class="layui-bg-gray" style="padding: 30px;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="layui-panel">
                    <!--四个按钮-->
                    <div>
                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                            <legend>新冠肺炎实时疫情数据展示---统计截止时间:<span th:text="${#dates.format(chinaTotal.updateTime,'yyyy-MM-dd HH:mm:ss')}"></span></legend>
                        </fieldset>
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-lg" th:text="'确诊:'+${chinaTotal.confirm}">默认按钮</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-lg"  th:text="'输入病例:'+${chinaTotal.input}">百搭按钮</button>
                            <button type="button" class="layui-btn layui-btn-warm layui-btn-lg"  th:text="'治愈病例:'+${chinaTotal.heal}">暖色按钮</button>
                            <button type="button" class="layui-btn layui-btn-danger layui-btn-lg"  th:text="'死亡人数:'+${chinaTotal.dead}">警告按钮</button>
                        </div>
                    </div>
                    <!--放入地图-->
                    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
                    <div id="main" style="width: 700px;height:600px;"></div>
                </div>
            </div>
            <div class="layui-col-md4">
                <div class="layui-panel">
                    <!--轮播图-->
                    <div class="layui-carousel" id="test1" lay-filter="test1">
                        <div carousel-item="">
                            <div><img style="height: 100%;width: 100%;" th:src="@{/images/banner3.jpg}"/></div>
                            <div><img style="height: 100%;width: 100%;" th:src="@{/images/banner2.jpg}"/></div>
                            <div><img style="height: 100%;width: 100%;" th:src="@{/images/banner1.jpg}"/></div>
                            <div><img style="height: 100%;width: 100%;" th:src="@{/images/banner2.jpg}"/></div>
                            <div><img style="height: 100%;width: 100%;" th:src="@{/images/banner3.jpg}"/></div>
                        </div>
                    </div>
                    <!--新闻-->
                    <div style="padding-top: 10px">
                        <ul class="layui-timeline">
                            <li  th:each="n : ${newsList}" class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <h3 class="layui-timeline-title" th:text="${#dates.format(n.createTime,'yyyy-MM-dd HH:ss')}">8月18日</h3>
                                    <p>
                                        <br><span class="layui-badge layui-bg-orange">标题:</span><span th:text="${n.title}"></span>
                                        <br><span class="layui-badge layui-bg-green">内容:</span><span th:text="${n.content}"></span>
                                        <br><span class="layui-badge layui-bg-blue">发布者:</span><span th:text="${n.publishby}"></span>
                                    </p>
                                </div>
                            </li>
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title">过去</div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 内容主体区域 -->
<!--    <div style="padding: 15px;">-->

<!--    </div>-->
</div>
<script>
    //JS
    layui.use(['carousel','element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,carousel = layui.carousel
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });

        //轮播图
        //常规轮播
        carousel.render({
            elem: '#test1'
            ,arrow: 'always'
            ,height:'220px'
            ,width:'480px'
        });
    });
</script>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    var dataList = [];
    option = {
        tooltip: {
            triggerOn: "click",
            formatter: function(e, t, n) {
                return '.5' == e.value ? e.name + "：有疑似病例" : e.seriesName + "<br />" + e.name + "：" + e.value
            }
        },
        toolbox: {
            show: true,
            orient: 'vertical',
            left: 'right',
            top: 'center',
            feature: {
                dataView: {readOnly: false},
                restore: {},
                saveAsImage: {}
            }
        }, // 提供下载工具
        visualMap: {
            min: 0,
            max: 100000,
            left: 26,
            bottom: 40,
            showLabel: !0,
            text: ["高", "低"],
            pieces: [{
                gt: 10000,
                label: "> 10000人",
                color: "#7f1100"
            }, {
                gte: 1000,
                lte: 10000,
                label: "1000 - 10000人",
                color: "#ff5428"
            }, {
                gte: 100,
                lt: 1000,
                label: "100 - 1000人",
                color: "#ff8c71"
            }, {
                gt: 10,
                lt: 100,
                label: "10 - 100人",
                color: "#ffd768"
            }, {
                gt: 1,
                lt: 10,
                label: "1 - 10人",
                color: "#ffffff"
            }],
            show: !0
        },
        geo: {
            map: "china",
            roam: !1,
            scaleLimit: {
                min: 1,
                max: 2
            },
            zoom: 1.23,
            top: 120,
            label: {
                normal: {
                    show: !0,
                    fontSize: "14",
                    color: "rgba(0,0,0,0.7)"
                }
            },
            itemStyle: {
                normal: {
                    //shadowBlur: 50,
                    //shadowColor: 'rgba(0, 0, 0, 0.2)',
                    borderColor: "rgba(0, 0, 0, 0.2)"
                },
                emphasis: {
                    areaColor: "#f2d5ad",
                    shadowOffsetX: 0,
                    shadowOffsetY: 0,
                    borderWidth: 0
                }
            }
        }
    };

    // 疫情数据前端ajax请求
    $.ajax({
        url: '/query',
        dataType: 'json',
        success: function(data) {
            for (let i in data){
                dataList[i] = data[i];
            }
            myChart.setOption({
                series:[
                    {
                        name: '确诊病例',
                        type: 'map',
                        geoIndex: 0,
                        data: dataList
                    }
                ]
            })
        }
    })

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>
</body>
</html>